package cn.wolfcode.trip.base.domain;

import cn.wolfcode.trip.base.util.JSONUtil;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Getter;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

@Getter@Setter
public class StrategyComment {  //评论

    public static final int STATE_NORMAL = 0;//正常
    public static final int STATE_COMMENT = 1;//推荐
    public static final int STATE_SHUT = 2;//禁用

    private Long id; //id

    private User user;//用户

    @JsonFormat(pattern = "yyyy-MM-dd ",timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date createTime;//创建评论时间

    private String content;//评论内容

    private String imgUrls;//图片

    private String[] imgUrlss;//图片

    private Integer starNum;//星级

    private Strategy strategy;//攻略

    private Integer state = STATE_NORMAL;//状态

    @JsonFormat(pattern = "yyyy-MM-dd ",timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date commendTime;//评论时间

    private Tag tag;//标签

    public String getStateString(){
        if (state ==0){
            return"正常";
        }else if(state == 1){
            return "推荐";
        }else if(state == 2){
            return "禁用";
        }
        return "";
    }
    //编辑框的回显
    public String getJsonString(){
        Map<String,Object> map = new HashMap<>();
        map.put("id",id);
        map.put("state",state);
        return JSONUtil.toJSONString(map);
    }
}